#include <iostream>
#include <typeinfo>
using namespace std;

class X{
	virtual void foo(void) {}
};
class Y:public X{
	void foo (void) {}
};
class Z:public X{
	void foo (void) {}
};

void func (X& x){
	if (typeid(x) == typeid(Y)) {
		cout << "针对Y子对象的处理" << endl;
	} else if (typeid(x) == typeid(Z)) {
		cout << "针对Z子对象的处理" << endl;
	}
}


int main (void) 
{
	int a; 
	cout << typeid(a).name() << endl;//i 类型信息的描述
	cout << typeid(int).name() << endl;//i
	
	int *arr1[10];
	int (*arr2)[10];
	cout << typeid(arr1).name() << endl; //A10_Pi
	cout << typeid(arr2).name() << endl; //PA10_i

	int (*p[5]) (int);
	cout << typeid(p).name() << endl; //A5_PFiiE

	Y y;
	Z z;
	func (y);
	func (z);
	return 0;
	return 0;
}
